<?php
namespace app\zhihui\controller;

use app\common\model\ZhVideo as ZhVideoModel;
use app\home\controller\Base;

/**
 * 佛教视频控制器
 * Class Zhmusic
 * @package app\index\controller
 */
class Zhvideo extends Base
{
    /**
     * [index  列表]
     * @return json
     * @author [C。]
     */
    public function index()
    {
        $param = input('param.');
        $model = new ZhVideoModel;
        $this->getPageAndSize($param);
        $map = [];
        try {
            if (!empty($param['cid'])) {
                $map['cid'] = $param['cid'];
            }
            $map['states'] = 1;
            $map['comid'] = $param['comid'];
            $count = $model->getCount($map);//满足条件的总数
            $allpage = intval(ceil($count / $this->size));//总页数
            $lists = $model->getlist($map, $this->from, $this->size, 'id,title,img,read_num,jread_num');
        } catch (\Exception $e) {
            systembug($e->getMessage(),2,$this->url);
            return admin_json(-1, $e->getMessage());
        }
        return admin_json(1, '获取成功', [
            'count' => $count,//总记录数
            'allpage' => $allpage,  //总页数
            'lists' => $lists,  //列表数据
        ]);
    }
}